/*
 * 标准开发模式下，使用Log filter的范例 
 * 
 * @author yangw
 * @since 1.0.0
 */
standard.controller('LogPushCtrl', function($rootScope, $scope, restfull){	
	$scope.logs = [];
	$scope.logsize = 0;
	$scope.debuglogs = [];
	$scope.debuglogsize = 0;
	$scope.errorlogs = [];
	$scope.errorlogsize = 0;
	
	
	/*创建一批日志*/
	$scope.creatlog = function(){
		restfull.query('/service/standard/createlog', {}, function(resp) { });
	}
	$scope.creatlog();
	
	/*获得推送过来的日志消息，并进行处理。详情请查询config.js中的关联代码*/
	$rootScope.pushmsg_log = function(msg){
		if(msg.datas.msglevel == 'debug'){
			msg.datas.msglevel = 'info';
			$scope.debuglogsize = $scope.debuglogs.push(msg);
		}else if(msg.datas.msglevel == 'info'){
			msg.datas.msglevel = 'primary';
		}else if(msg.datas.msglevel == 'warn'){
			msg.datas.msglevel = 'warning';
		}else if(msg.datas.msglevel == 'error'){
			msg.datas.msglevel = 'danger';
			$scope.errorlogsize = $scope.errorlogs.push(msg);
		}

		$scope.logsize = $scope.logs.push(msg);
		$scope.$apply(); //ng-click只会触发一次循环，而推送到消息需要实时循环。
	}

});
